﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Bussiness;
namespace EWebsite
{
    public partial class Category : System.Web.UI.Page
    {
        private DataTable _tlbProducts;
        int catID = -1;
        public DataTable TlbProducts {
            get { return _tlbProducts; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                try {
                    catID = int.Parse(Request["cat"]);
                }
                catch (Exception ex) { }         
            }
        }

        protected void _dataBind() {
            ProductBuss pBuss = new ProductBuss();            
            
            if (catID <= -1) {
                _tlbProducts = pBuss.getProducts();
                listViewProducts.DataSource = _tlbProducts;
                listViewProducts.DataBind();
            }
            else {
                _tlbProducts = pBuss.getProducts(catID);
                listViewProducts.DataSource = _tlbProducts;
                listViewProducts.DataBind();
            } 
        }

        protected void DataPagerProducts_PreRender(object sender, EventArgs e) {
            _dataBind();
        }
    }
}